import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:myapp/bean/article.dart';
import 'package:myapp/globle/route_manager.dart';
import 'package:myapp/util/colors_utils.dart';

class ItemArticleWidget2 extends StatelessWidget {
  final Article article;

  const ItemArticleWidget2({Key key,@required this.article}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      child: Container(
        color: ColorUtils.color_bg_1,
        child: Padding(
          padding: EdgeInsets.symmetric(vertical: 10, horizontal: 8),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(article.title,
                  style: TextStyle(color: ColorUtils.color_text_1)),
              Padding(padding: EdgeInsets.fromLTRB(0, 8, 0, 0)),
              Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
                  if (article.fresh && !article.top)
                    Padding(
                        padding: EdgeInsets.only(right: 4),
                        child: Text(
                          "新",
                          style:
                              TextStyle(fontSize: 13, color: Colors.redAccent),
                        )),
                  Padding(
                    padding: EdgeInsets.only(right: 4),
                    child: Text(
                      article.author.isEmpty
                          ? article.shareUser
                          : article.author,
                      style: TextStyle(
                          fontSize: 13, color: ColorUtils.color_text_2),
                    ),
                  ),
                  Text(
                    article.niceDate,
                    style:
                        TextStyle(fontSize: 13, color: ColorUtils.color_text_3),
                  ),
                  Expanded(child: SizedBox.shrink()),
                  InkWell(
                    child: Icon(
                      Icons.star_border,
                      size: 18,
                      color: ColorUtils.color_text_3,
                    ),
                    onTap: () {},
                  )
                ],
              )
            ],
          ),
        ),
      ),
      onTap: () {
        Navigator.pushNamed(context, RouteName.ARTICLE_DETAIL_PAGE,
            arguments: article);
      },
    );
  }
}
